package com.jiang.daily.Q2598;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/10/16 11:14
 */
class Solution {
    public int findSmallestInteger(int[] nums, int value) {
        int[] mp = new int[value];
        for (int n: nums) {
            // mp[(n % value + value) % value]++;
            int temp = n % value;
            if (temp < 0) temp += value;
            mp[temp]++;
        }

        int mex = 0;

        while (mp[mex % value]-- > 0) {
            mex++;
        }

        return mex;
    }
}
